﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectSchedule.Entity
{
    /// <summary>
    /// 舾装分段计划汇总
    /// </summary>
    public class XZSectionPlan_Section
    {
        public XZSectionPlan_Section() { }

        public XZSectionPlan_Section(DateTime PreassembleStopTime, XZSectionTime_Section SectionTime) 
        {
            if (PreassembleStopTime == null) return;
            this.ShipName = SectionTime.ShipName;
            this.SectionName = SectionTime.SectionName;

            this.PreassembleStop = PreassembleStopTime;
            int offsetDays = SectionTime.Preassemble;
            this.PreassembleStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.PretreatInterval;
            this.PretreatStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Pretreat;
            this.PretreatStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.IntestInterval;
            this.IntestStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Intest;
            this.IntestStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.PolishInterval;
            this.PolishStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Polish;
            this.PolishStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.WeldInterval;
            this.WeldStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Weld;
            this.WeldStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.MoldingInterval;
            this.MoldingStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Molding;
            this.MoldingStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            offsetDays += SectionTime.CuttingInterval;
            this.CuttingStop = PreassembleStopTime.AddDays(-offsetDays);
            offsetDays += SectionTime.Cutting;
            this.CuttingStart = PreassembleStopTime.AddDays(-offsetDays + 1);

            this.PlanSectionTime = SectionTime;
        }

        public string ShipName { get; set; }
        public string SectionName { get; set; }
        public double Weight { get; set; }

        /// <summary>
        /// 舾装下料工期
        /// </summary>
        public DateTime CuttingStart { get; set; }
        public DateTime CuttingStop { get; set; }
        /// <summary>
        /// 舾装成型工期
        /// </summary>
        public DateTime MoldingStart { get; set; }
        public DateTime MoldingStop { get; set; }
        /// <summary>
        /// 舾装焊接工期
        /// </summary>
        public DateTime WeldStart { get; set; }
        public DateTime WeldStop { get; set; }
        /// <summary>
        /// 舾装打磨工期
        /// </summary>
        public DateTime PolishStart { get; set; }
        public DateTime PolishStop { get; set; }
        /// <summary>
        /// 舾装内场实验工期
        /// </summary>
        public DateTime IntestStart { get; set; }
        public DateTime IntestStop { get; set; }
        /// <summary>
        /// 预制工期
        /// </summary>
        public DateTime PretreatStart { get; set; }
        public DateTime PretreatStop { get; set; }
        /// <summary>
        /// 舾装分段预装工期
        /// </summary>
        public DateTime PreassembleStart { get; set; }
        public DateTime PreassembleStop { get; set; }

        public XZSectionTime_Section PlanSectionTime { get; set; }
        public XZProcessUnit_Section Units { get; set; }

    }
    /// <summary>
    /// 舾装区域计划汇总
    /// </summary>
    public class XZSectionPlan_Area
    {
        public XZSectionPlan_Area() { }

        public XZSectionPlan_Area(DateTime BulkStartTime, XZSectionTime_Area AreaTime)
        {
            if (BulkStartTime == null) return;
            this.ShipName = AreaTime.ShipName;
            this.AreaName = AreaTime.AreaName;

            this.BulkStart = BulkStartTime;
            int offsetDays = AreaTime.Bulk;
            this.BulkStop = BulkStartTime.AddDays(offsetDays - 1);

            offsetDays += AreaTime.DockProjectInterval;
            this.DockProjectStart = BulkStartTime.AddDays(offsetDays - 1);
            offsetDays += AreaTime.DockProject;
            this.DockProjectStop = BulkStartTime.AddDays(offsetDays);

            offsetDays += AreaTime.TrialTripInterval;
            this.TrialTripStart = BulkStartTime.AddDays(offsetDays - 1);
            offsetDays += AreaTime.TrialTrip;
            this.TrialTripStop = BulkStartTime.AddDays(offsetDays);

            offsetDays += AreaTime.DeliveryInterval;
            this.Delivery = BulkStartTime.AddDays(offsetDays - 1);


            offsetDays = AreaTime.PretreatInterval;
            this.PretreatStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Pretreat;
            this.PretreatStart = BulkStartTime.AddDays(-offsetDays);

            offsetDays = AreaTime.IntestInterval;
            this.IntestStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Intest;
            this.IntestStart = BulkStartTime.AddDays(-offsetDays);

            offsetDays = AreaTime.PolishInterval;
            this.PolishStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Polish;
            this.PolishStart = BulkStartTime.AddDays(-offsetDays);

            offsetDays = AreaTime.WeldInterval;
            this.WeldStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Weld;
            this.WeldStart = BulkStartTime.AddDays(-offsetDays);

            offsetDays = AreaTime.MoldingInterval;
            this.MoldingStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Molding;
            this.MoldingStart = BulkStartTime.AddDays(-offsetDays);

            offsetDays = AreaTime.CuttingInterval;
            this.CuttingStop = BulkStartTime.AddDays(-offsetDays - 1);
            offsetDays += AreaTime.Cutting;
            this.CuttingStart = BulkStartTime.AddDays(-offsetDays);


            this.PlanAreaTime = AreaTime;
        }

        public string ShipName { get; set; }
        public string AreaName { get; set; }
        public double Weight { get; set; }

        /// <summary>
        /// 舾装下料工期
        /// </summary>
        public DateTime CuttingStart { get; set; }
        public DateTime CuttingStop { get; set; }
        /// <summary>
        /// 舾装成型工期
        /// </summary>
        public DateTime MoldingStart { get; set; }
        public DateTime MoldingStop { get; set; }
        /// <summary>
        /// 舾装焊接工期
        /// </summary>
        public DateTime WeldStart { get; set; }
        public DateTime WeldStop { get; set; }
        /// <summary>
        /// 舾装打磨工期
        /// </summary>
        public DateTime PolishStart { get; set; }
        public DateTime PolishStop { get; set; }
        /// <summary>
        /// 舾装内场实验工期
        /// </summary>
        public DateTime IntestStart { get; set; }
        public DateTime IntestStop { get; set; }
        /// <summary>
        /// 预制工期
        /// </summary>
        public DateTime PretreatStart { get; set; }
        public DateTime PretreatStop { get; set; }
        /// <summary>
        /// 舾装散装工期
        /// </summary>
        public DateTime BulkStart { get; set; }
        public DateTime BulkStop { get; set; }
        /// <summary>
        /// 舾装码头工程工期
        /// </summary>
        public DateTime DockProjectStart { get; set; }
        public DateTime DockProjectStop { get; set; }
        /// <summary>
        /// 舾装试航工期
        /// </summary>
        public DateTime TrialTripStart { get; set; }
        public DateTime TrialTripStop { get; set; }
        /// <summary>
        /// 交船
        /// </summary>
        public DateTime Delivery { get; set; }

        public XZSectionTime_Area PlanAreaTime { get; set; }
        public XZProcessUnit_Area Units { get; set; }

    }
    public class XZSectionPlan_Debug
    {
        public XZSectionPlan_Debug() { }

        public XZSectionPlan_Debug(DateTime DebugedTime, XZSectionTime_Debug DebugTime)
        {
            if (DebugedTime == null) return;
            this.ShipName = DebugTime.ShipName;
            this.ProjectName = DebugTime.ProjectName;
            this.DebuggingStop = DebugedTime;
            this.DebuggingStart = DebuggingStop.AddDays(-1 * DebugTime.Debugging + 1);

            this.PlanTime = DebugTime;
        }

        public string ShipName { get; set; }
        public string ProjectName { get; set; }

        /// <summary>
        /// 调试工期
        /// </summary>
        public DateTime DebuggingStart { get; set; }
        public DateTime DebuggingStop { get; set; }

        public XZSectionTime_Debug PlanTime { get; set; }
        public XZProcessUnit_Debug Units { get; set; }
    }
}
